<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,height=device-height,initial-scale=1,user-scalable=0,viewport-fit=cover">
    <meta name="wechat-enable-text-zoom-em" content="true">
    <link rel="stylesheet" href="https://res.wx.qq.com/open/libs/weui/2.3.0/weui.min.css"/>
    <title>简易聊天室后台</title>
    <script>

        function clearAllChat() {
            const xhr = new XMLHttpRequest();
            xhr.open('GET', 'admin.php?action=clearAllChat', true);
            xhr.onload = function () {
                if (this.status === 200) {
                    nowMessage = this.responseText;
                    if (nowMessage !== lastMessage) {
                        document.getElementById('messages').innerHTML = nowMessage;
                        scrollToBottom();
                        lastMessage = nowMessage;
                    }
                }
            }
            xhr.send();
        }

        function clearHot() {
            const xhr = new XMLHttpRequest();
            xhr.open('GET', 'admin.php?action=clearHot', true);
            xhr.send();
        }

    </script>

    <style>
        /* 鼠标悬停时的样式 */
        button:hover {
            cursor: pointer; /* 鼠标变成手形 */
            background-color: #4CAF50; /* 移入时的背景颜色 */
        }

        /* 鼠标点击时的样式 */
        button:active {
            background-color: #45a049; /* 点击时的背景颜色 */
        }
    </style>
</head>
<body>

<div id="nickname_page" class="page">

        <div class="weui-form__ft">
            <div class="weui-form__opr-area">
                <button onclick="clearAllChat()" class="weui-btn weui-btn_primary">清除聊天记录</button>
            </div>
        </div>
        <div class="weui-form__ft">
            <div class="weui-form__opr-area">
                <button onclick="clearHot()" class="weui-btn weui-btn_primary">清除热度</button>
            </div>
        </div>
    </div>

</div>

</body>

</html>

